import { patient_rivermead_info } from '@/services/patient';
import { ProDescriptions } from '@ant-design/pro-components';
import { Divider, Modal, Radio, Spin, Typography } from 'antd'
import React, { useEffect, useState } from 'react'
const { Title } = Typography;
import './rivermead.less'

interface Iprops {
    isShowRivermeadOnline: (show: boolean) => void;
    onlineRivermeadModalOpen: boolean;
    onlineId: number | undefined;
}
const OnlineRivermeadInfo = (props: Iprops) => {
    const { isShowRivermeadOnline, onlineRivermeadModalOpen, onlineId } = props
    // 存储评估详情
    const [rivermeadInfo, setRivermeadInfo] = useState<any>(undefined);
    // 评估内容
    const [content, setcontent] = useState<any>(undefined);
    // 页面初始化
    useEffect(() => {
        // 获取运动指数评估详情
        const getData = async () => {
            if (onlineId) {
                let res: any = await patient_rivermead_info({ id: onlineId });
                console.log('运动指数详情', res);
                if (res.code == 200) {
                    setRivermeadInfo(res.data);
                    console.log('运动指数', res.data.content, JSON.parse(res.data.content));
                    setcontent(JSON.parse(res.data.content));
                }
            }
        };
        getData();
    }, []);

    // 评估详情
    const get_oldinfo = async () => {
        return {
            data: rivermeadInfo,
        };
    };
    return (
        <Modal
            title="运动指数评估详情"
            open={onlineRivermeadModalOpen}
            onCancel={() => isShowRivermeadOnline(false)}
            footer={null}
            width={1500}
        >
            <Divider />
            <Typography>
                {/* 评估详情 */}
                {rivermeadInfo === undefined ? (
                    <div
                        style={{
                            margin: '20px 0',
                            marginBottom: '20px',
                            padding: '30px 50px',
                            textAlign: 'center',
                        }}
                    >
                        <Spin size="large" />
                    </div>
                ) :
                    <>
                        <ProDescriptions
                            column={3}
                            request={async (params) => get_oldinfo()}
                            columns={[
                                {
                                    title: '评估时间',
                                    key: 'create_time',
                                    dataIndex: 'create_time',
                                },
                                {
                                    title: '评估驿站',
                                    key: 'poststation_name',
                                    dataIndex: 'poststation_name',
                                },
                                {
                                    title: '评估结果',
                                    key: 'results',
                                    dataIndex: 'results',
                                },
                            ]}
                        ></ProDescriptions>
                        <Title level={5}>Rivermead运动指数</Title>
                        <div style={{ display: 'flex', flexWrap: 'wrap' }}>
                            <div className="question_item">
                                <div className="question_title1">自己从仰卧位转成侧卧位</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_1 || content.question_1 == 0 ? content.question_1 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">自己从卧位坐起来，并坐在床边</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_2 || content.question_2 == 0 ? content.question_2 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">自己坐在床边10秒钟</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_3 || content.question_3 == 0 ? content.question_3 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">在15秒中内从椅子上站起来并保持站立15秒（必要时可手扶物体或用助具）</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_4 || content.question_4 == 0 ? content.question_4 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">独自站立10秒钟</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_5 || content.question_5 == 0 ? content.question_5 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">不用帮助，自己从床转移到椅子上，再回到床上</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_6 || content.question_6 == 0 ? content.question_6 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">在室内行走10米（可以借助助行器、室内家具、但不用他人帮助）</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_7 || content.question_7 == 0 ? content.question_7 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">自己上一层楼的楼梯</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_8 || content.question_8 == 0 ? content.question_8 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">不用他人帮助，在人行道上行走</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_9 || content.question_9 == 0 ? content.question_9 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">在室内独自行走10米（不用任何帮助，包括夹板、助行器、家具或其他人的帮助）</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_10 || content.question_10 == 0 ? content.question_10 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">自己走5米，拾起掉在地上的物体，再走回来</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_11 || content.question_11 == 0 ? content.question_11 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">自己在不平整的地面上行走（如草地、砂石地、斜坡等）</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_12 || content.question_12 == 0 ? content.question_12 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">自己进出浴室并自己洗澡</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_13 || content.question_13 == 0 ? content.question_13 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">不用他人帮助，不抓扶手上下四节楼梯（必要时可用助行器）</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_14 || content.question_14 == 0 ? content.question_14 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                            <div className="question_item">
                                <div className="question_title1">跑或快速走10米而没有跛行或者出现跛行不到4秒钟</div>
                                <div className="question_answer1">
                                    <Radio.Group value={content.question_15 || content.question_15 == 0 ? content.question_15 : ""}>
                                        <Radio value={'1'} key={1}>
                                            是
                                        </Radio>
                                        <Radio value={'0'} key={0}>
                                            否
                                        </Radio>
                                    </Radio.Group>
                                </div>
                            </div>
                        </div>
                    </>}
            </Typography>
        </Modal>
    )
}
export default OnlineRivermeadInfo